<section id="static_analysis">
    {% load key_tags %}
        {% if file.office %}
            {% if file.mmbot %}
                <div>
                    <div id="mmbot_results">
                        <h4>Malicious Macro Bot Results</h4>
                        <table class="table table-striped table-bordered">
                            <colgroup>
                                <col width="250" />
                                <col width="*" />
                            </colgroup>
                            {% for key, value in file.mmbot.items|dictsort:0 %}
                                <tr>
                                    <td>{{key}}</td>
                                    <td>{{value}}</td>
                                </tr>
                            {% endfor %}
                        </table>
                    </div>
                </div>
            {% endif %}
            {% if file.office.Metadata %}
                {% if file.office.Metadata.SummaryInformation %}
                <div>
                    <div id="si_metadata">
                        <h4>SummaryInformation Metadata</h4>
                        <table class="table table-striped table-bordered">
                            <colgroup>
                                <col width="250" />
                                <col width="*" />
                            </colgroup>
                            {% for key, value in file.office.Metadata.SummaryInformation.items|dictsort:0 %}
                                <tr>
                                    <td>{{key}}</td>
                                    <td>{{value}}</td>
                                </tr>
                            {% endfor %}
                        </table>
                    </div>
                </div>
                <hr />
                {% endif %}
                {% if file.office.Metadata.DocumentSummaryInformation %}
                <div>
                    <div id="dsi_metadata">
                        <h4>DocumentSummaryInformation Metadata</h4>
                        <table class="table table-striped table-bordered">
                            <colgroup>
                                <col width="250" />
                                <col width="*" />
                            </colgroup>
                            {% for key, value in file.office.Metadata.DocumentSummaryInformation.items|dictsort:0 %}
                                <tr>
                                    <td>{{key}}</td>
                                    <td>{{value}}</td>
                                </tr>
                            {% endfor %}
                        </table>
                    </div>
                </div>
                <hr />
                {% endif %}
            {% endif %}
            {% if file.office.Macro %}
                {% if file.office.Macro.Analysis %}
                    <div id="analysis_sigs">
                        <h4>File Analysis (Signatures)</h4>
                        {% for detection in file.office.Macro.Analysis %}
                        <div>
                            <div class="panel" id="accordion" style="margin-top: 20px;">
                            <div class="card-header">
                                <a class="accordion-toggle" data-parent="#analysis_sigs" data-toggle="collapse" href="#{{detection}}" aria-expanded="false"><i class="icon icon-cog"></i>{{detection}}</a>
                            </div>
                            <div id="{{detection}}" class="panel-collapse collapse" style="text-align: left;">
                                <table class="table table-striped table-bordered">
                                <colgroup>
                                    <col width="200">
                                    <col width="*">
                                </colgroup>
                                <th colspan="2">{{detection}}</th>
                                {% for indicator, description in file.office.Macro.Analysis|getkey:detection %}
                                    <tr>
                                        <td>{{indicator}}</td>
                                        <td>{{description}}</td>
                                    </tr>
                                {% endfor %}
                                </table>
                            </div>
                            </div>
                        {% endfor %}
                    </div>
                </div>
                <hr />
                {% endif %}
                {% if file.office.Macro.Code and not file.office.XLMMacroDeobfuscator %}
                <div>
                    <div id="macro">
                    <h4>Extracted Macros</h4>
                    {% for macrodata in file.office.Macro.Code %}
                    <table class="table table-striped table-bordered">
                        <col style="width:20%">
                        <col style="width:60%">
                        <col style="width:20%">
                        {% for name, code in file.office.Macro.Code|getkey:macrodata %}
                        <tr>
                            <td>VBA Filename</td>
                            <td>{{name}}</td>
                            <td><a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#{{macrodata}}">Extracted Macro</a></td>
                        </tr>
                        </table>
                        <div id="{{macrodata}}" class="collapse">
                            <pre>{{code}}</pre>
                        </div>
                        {% endfor %}
                    {% endfor %}
                    </div>
                </div>
                {% endif %}
            {% endif %}
        {% endif %}
        {% if file.office_rtf %}
            <div>
                <div id="si_metadata">
                    <h4>RTF document details</h4>
                    <table class="table table-striped table-bordered">
                        {% for key, value in file.office_rtf.items %}
                            <h5>Object ID: {{key}}</h5>
                            <tr>
                                <th width=10%>Filename</th>
                                <td>Size</td>
                                <th>Index</th>
                                <td>Class Name</td>
                                <td>Type Embed</td>
                                <th>CVE</th>
                            </tr>
                            {% for block in value %}
                                <tr>
                                    {% if block.sha256 %}
                                        <td><a href={% url "file" "rtf" file.info.id block.sha256 %} class="btn btn-secondary btn-small">{{block.filename}}</a></td>
                                    {% else %}
                                        <td>{{block.filename}}</td>
                                    {% endif %}
                                    <td>{{block.size}}</td>
                                    <td>{{block.index}}</td>
                                    <td>{{block.class_name}}</td>
                                    <td>{{block.type_embed}}</td>
                                    <td>{{block.CVE}}</td>
                                </tr>
                            {% endfor %}
                        {% endfor %}
                    </table>
                </div>
            </div>
            <hr />
        {% endif %}
        {% if file.office_dde %}
        <div id="si_metadata">
        <table class="table table-striped table-bordered">
            <colgroup>
                <col width="200" />
                <col width="*" />
            </colgroup>
            <tr>
                <td><h4>DDE Detected</h4></td>
                <td>{{file.office_dde}}</td>
            </tr>
        </table>
        </div>
{% endif %}
</section>
